#include<iostream>
using namespace std;
#include<iomanip>
#include<cmath>

double Sup(long int N){
	double y=0;
	for(long int i=1;i<=N;i++){
		y += 1.0/i;
	}
	return y;
}

double Sdown(long int N){
	double y=0;
	for(long int i=N;i>=1;i--){
		y += 1.0/i;
	}
	return y;
}

int main(){

	FILE *fp=fopen("exe6.data","w");
	if(fp==NULL)cout<<"error: failed to open exe6.data"<<endl;
	long int NN[10]={10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000};
	cout<<"NN:"; for(int i=0;i<10;i++)cout<<NN[i]<<","; cout<<endl;
	double s1,s2;
	for(int i=1;i<=10;i++){
		cout<<"i="<<i<<endl;
		s1=Sup(NN[i-1]);
		s2=Sdown(NN[i-1]);
		fprintf(fp,"%d \t %lf \n", i, log10( fabs((s1-s2)/s2) ) );
	}
	fclose(fp);
	return 0;
}
